<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>档案管理</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script type="text/javascript" src="libs/handlebars.min.js"></script>
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>

<script type="text/javascript" src="libs/d3.v3.min.js"></script>
<!-- d3放在前面 -->
<script type="text/javascript" src="libs/nv.d3.min.js"></script>
<!-- nv在后面 -->
<link href="libs/bootstrap-3.3.6/css/nv.d3.min.css">
<script type="text/javascript" src="libs/dateFormat.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					<strong>档案管理</strong>
				</h2>
				<div style="margin-left: 900px">
					<div class="input-group">
						<input type="text" id="shuru" class="form-control"
							placeholder="输入档案号或身份证号"> <span class="input-group-btn">
							<button id="chaxun" class="btn btn-default" type="button">Go!</button>
						</span>
					</div>
					<!-- /input-group -->
				</div>
			</div>
			<div class="col-md-8">
				<ul class="nav nav-pills">
					<li class="active"><a href="#">首页</a></li>
					<li class=""><a href="add.html">添加</a></li>
					<li class=""><a href="mohuquery.html">查询</a></li>
				</ul>
			</div>
			<div class="col-md-3 col-md-offset-1">
				<ul class="nav nav-pills">
					<li><a href="#">用户：<span id="account"></span></a></li>
					<li class=""><a href="register.html">注册</a></li>
					<li><button id="quit" class="btn btn-block">退出</button></li>

				</ul>
			</div>
		</div>
	</div>
	<div class="contrainer">
		<div class="row">
			<div class=cil-md-12>
				<hr />
			</div>
		</div>
	</div>
	<div class="container">
		<div class=col-md-12>
			<div class="panel panel-warning">
				<div class="panel-heading">
					<h4>某个时间范围内的上传数</h4>
				</div>
				<div class="panel-body" id="text2">
					起始时间<input type="date" id="date1" value="">
					&nbsp;&nbsp;&nbsp; 结束时间<input type="date" id="date2">
					<button id="tijiao" class="btn btn-default" type="button">查找</button>
				</div>
				<div class="panel-body" id="text3"></div>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12" id="chart">
				<p class="text-center">
					<br>
				<hr>
				<strong>每个用户上传数</strong>
				<svg style="height: 480px; width: 100%"></svg>
				<br>
			</div>
			<!-- 			<div class=col-md-6>
				<div class="panel panel-warning">
					<div class="panel-heading">
						<h4>一周的总支出</h4>
					</div>
					<div class="panel-body" id="text2"></div>
				    </div>
			</div> -->
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-primary">
					<div class="panel-heading">
						<h4>最近浏览的4个档案</h4>
					</div>
					<div class="panel-body" id="list1"></div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-success">
					<div class="panel-heading">
						<h4>最近添加的4个档案</h4>
					</div>
					<div class="panel-body" id="list2"></div>
				</div>
			</div>
		</div>
	</div>
	<script id="template" type="text/x-handlebars-template">
  {{#each item}}
  <div class="panel panel-default col-md-3">
    <div class="panel-body"> 
     <dl>
       <dt>id</dt><dd>{{id}}</dd>
       <dt>档案号</dt><dd>{{archive_id}}</dd>
       <dt>身份证号</dt><dd>{{identity}}</dd>
       <dt>姓名</dt><dd>{{name}}</dd>
       <dt>性别</dt><dd>{{gender}}</dd>
       <dt>特殊工种</dt><dd>{{sp}}</dd>
       <dt>女管理岗位</dt><dd>{{fc}}</dd>
       <dt>工龄</dt><dd>{{seniority}}</dd>
    </dl>
   </div>
  </div>
 {{/each}}
</script>
	<script id="template1" type="text/x-handlebars-template">
 {{#each item}}
  <div class="panel panel-default col-md-3">
    <div class="panel-body"> 
     <dl>
       <dt>昵称:</dt><dd>{{nickname}}</dd>
       <dt>上传数量:</dt><dd>{{counter}}</dd>
    </dl>
   </div>
  </div>
 {{/each}}
</script>

</body>
<script type="text/javascript">
	$(function() {
		var d2 = new Date();
		$('#date2').val(d2.format('yyyy-MM-dd'));
		var d1 = new Date();
		$('#date1').val(d1.format('yyyy-MM-01'));
		$.getJSON('querynickname.action', function(res) {
			console.log(res);
			$('#account').text(res.nickname);
		})
		$('#quit').click(function() {
			$.post('quit.action', {}, function(res, status) {
				if ('OK' == res) {
					alert('退出成功');
					window.location.href = 'login.html';
				}
			});
		});
		$('#chaxun').click(function() {
			$.post('chaxun.action', {
				shuru : $('#shuru').val()
			}, function(res, stastu) {
				if ('dayuone' == res) {
					alert('有多个结果');
				} else if ('dengyuO' == res) {
					alert('输入有误');
				} else {
					console.log(res);
					window.location.href = 'one.html?id=' + res;
				}
			});
		});
		$.getJSON('tongjishangchuan.action', function(res) {
			nv.addGraph(function() {
				var chart = nv.models.pieChart().x(function(d) {
					return d.nickname
				}).y(function(d) {
					return d.counter
				}).showLabels(true).labelType('percent');
				d3.select("#chart svg").datum(res).transition().duration(350)
						.call(chart);
				return chart;
			});
		});
		$.getJSON('zjtjst.action', function(res) {
			console.log(res);
			var date = {
				'item' : res
			};
			var t = Handlebars.compile($('#template').html());
			$('#list2').html(t(date));
		});
		$.getJSON('zuijinlook.action', function(res) {
			console.log(res);
			var date = {
				'item' : res
			};
			var t = Handlebars.compile($('#template').html());
			$('#list1').html(t(date));
		});

		$('#tijiao').click(function() {
			$.getJSON('timesc.action', {
				date1 : $('#date1').val(),
				date2 : $('#date2').val()
			}, function(res, stastu) {
				var date = {
					'item' : res
				};
				var t = Handlebars.compile($('#template1').html());
				$('#text3').html(t(date));
			})
		})
	});
</script>
</html>